package com.cai.servlet.main;

import com.cai.dao.DetailedUserDao;
import com.cai.dao.impl.DetailedUserDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author RuoLi
 */
@WebServlet(name = "ServletUserMainUserInfo", value = "/userMain/userInfo")
public class ServletCustomerInfo extends HttpServlet {
    DetailedUserDao detailedUserDao = new DetailedUserDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        int userAccount = Integer.parseInt(req.getParameter("userAccount"));
        //查询账号是否编辑过信息
        detailedUserDao.setDefaultDetailedUserData(userAccount);
        //获取信息
        String data = detailedUserDao.showUserDetailedInfo(userAccount);
        req.getSession().setAttribute("detailedUserInfo",data);
        resp.getWriter().write(data);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
